home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Internet / WWW / GraphicTrak / gdreport < prev    next >
Encoding:
Text File  |  1996-01-16  |  1.5 KB  |  62 lines

  1. #!/usr/bin/perl
  2. # NOTE: The above may have to be changed to work with your system
  3.  
  4. # GraphicTrak Report
  5. # Copyright (c) 1996 Jumbo Inc.
  6. # Written by Jon Conlon
  7.  
  8. # Location of GrafDetect Image Supplier
  9. $location = "/bin/gdimage.supply";
  10.  
  11. # Log File
  12. $log_file = "/http-logs/access_log";
  13.  
  14. open(LOG, "$log_file") || die "cannot open $log_file";
  15.  
  16. while(<LOG>) {
  17.   # following commented out line tries to match end of line but may not 
  18.   # work with some access log formats; uncommented one is more flexible
  19.   # /^.+\x5b(\d{2})\/(\w{3})\/19\d{2}:\d{2}:\d{2}:\d{2} -\d{4}\x5d \"\w+ (\S+) \S+\" (\d{3})$/;
  20.   /^.+\x5b(\d{2})\/(\w{3})\/19\d{2}:\d{2}:\d{2}:\d{2} -\d{4}\x5d \"\w+ (\S+) \S+\" (\d{3})/;
  21.  
  22.   $date = $2 . ' ' . $1;
  23.   $file = $3;
  24.   $code = $4;
  25.  
  26.   if ($code == 200)
  27.   { # Successful HTTP Transfer
  28.     if ($file =~ /^$location/) {
  29.       $gd{$date}++;
  30.     }
  31.     elsif ( !($file =~ /\.gif$/i || $file =~ /\.jpg$/i || $file =~ /\.jpeg$/i || 
  32.         $file =~ /\.xbm$/i || $file =~ /\.cgi/ ) ) {
  33.       $total{$date}++;
  34.     } 
  35.   }
  36. }
  37.  
  38. close(LOG);
  39.  
  40. for (sort(keys %total)) {
  41.   $date = $_;
  42.  
  43.   $text  = ($total{$date} - $gd{$date}) * 100 / $total{$date};
  44.   $graph = $gd{$date} * 100 / $total{$date};
  45.  
  46.   write;
  47. }
  48.  
  49. format STDOUT_TOP =
  50. GraphicsTrak -- Copyright (C) 1996 Jumbo Inc.
  51.  
  52. Date      Graphics  Text       "Pages"    Pixels
  53. --------  --------  --------  --------  --------
  54. .
  55.  
  56. format STDOUT =
  57. @<<<<<<<  @>>>>>>>  @>>>>>>>  @>>>>>>>  @>>>>>>>
  58. $date,    $graph,   $text,    $total{$date}, $gd{$date}
  59. .
  60.  
  61. #eof
  62.